Skip to content

Conversation

@qianglbl
Copy link
Member

@qianglbl qianglbl commented Oct 6, 2025

added 3 input parameters for the 2.5D Gaussian solver, modified Gauss2p5dPush.cpp, added examples in fodo_space_charge.

Enhances the implementation from #1127

@qianglbl qianglbl requested review from ax3l and cemitch99 October 6, 2025 22:37
int tp5d_bins = 129;
pp_algo.queryAddWithParser("gauss2p5_bins", tp5d_bins);

// Measure beam size, extract the min, max of particle positions

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable x_min is not used.
int tp5d_bins = 129;
pp_algo.queryAddWithParser("gauss2p5_bins", tp5d_bins);

// Measure beam size, extract the min, max of particle positions

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable y_min is not used.
int tp5d_bins = 129;
pp_algo.queryAddWithParser("gauss2p5_bins", tp5d_bins);

// Measure beam size, extract the min, max of particle positions

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable x_max is not used.
int tp5d_bins = 129;
pp_algo.queryAddWithParser("gauss2p5_bins", tp5d_bins);

// Measure beam size, extract the min, max of particle positions

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable y_max is not used.
This was referenced Oct 7, 2025
@cemitch99
Copy link
Member

Great! Changing the tolerance now allows the test of the initial beam moments to pass in all cases. For the final beam moments, the Gauss3d test still fails in a few cases, and this does not appear to be due to noise or tolerance. (For example, the initial and final beam moments output by the test on macOS are identical to each other.)

@cemitch99
Copy link
Member

Summary of failed tests (on macOS / AppleClang, OpenMP / GCC w/MPI w/Python, Tooling / Clang ASAN UBSAN): FODO.Gauss3d.sc fails, and the initial and final beam moments are identical.

@qianglbl
Copy link
Member Author

qianglbl commented Oct 16, 2025 via email

// Input particle locations (x,y) and RMS sizes (sigx,sigy) and return the integrals for SC fields.
//
AMREX_GPU_DEVICE
void potInt(amrex::ParticleReal delta, int nint, amrex::ParticleReal xin, amrex::ParticleReal yin, amrex::ParticleReal sigx, amrex::ParticleReal sigy,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void potInt(amrex::ParticleReal delta, int nint, amrex::ParticleReal xin, amrex::ParticleReal yin, amrex::ParticleReal sigx, amrex::ParticleReal sigy,
void potInt (amrex::ParticleReal delta, int nint, amrex::ParticleReal xin, amrex::ParticleReal yin, amrex::ParticleReal sigx, amrex::ParticleReal sigy,

@cemitch99
Copy link
Member

I think I see why the remaining tests are failing now. I can help you resolve those tomorrow if you have time.


print("Initial Beam:")
sig_xi, sig_yi, sig_ti, emittance_xi, emittance_yi, emittance_ti = get_moments(initial)
sig_xi, sig_yi, sig_ti, emittance_xi, emittance_yi, emittance_ti = get_moments(final)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sig_xi, sig_yi, sig_ti, emittance_xi, emittance_yi, emittance_ti = get_moments(final)
sig_xi, sig_yi, sig_ti, emittance_xi, emittance_yi, emittance_ti = get_moments(initial)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial and final moments are switched here.

@cemitch99
Copy link
Member

@qianglbl It looks like the Gauss3d tests are all passing! The failing Gauss2p5d tests are now due to errors in the final sigma_x and sigma_y of around 10% and 5%, respectively. (The tolerance is 3%.) Those errors seems too large...

@cemitch99
Copy link
Member

@qianglbl @ax3l I tried running this test locally on my Mac with 12 OMP threads, and it worked fine. It is notable that the three failing checks above all return the same wrong answer.

Comment on lines 185 to 190
// Call charge deposition function
impactx::particles::wakefields::DepositCharge1D(pc, charge_distribution, bin_min, bin_size, is_unity_particle_weight);

// Call charge density derivative function
amrex::Gpu::DeviceVector<amrex::Real> slopes(charge_distribution.size() - 1, 0.0);
impactx::particles::wakefields::DerivativeCharge1D(charge_distribution, slopes, bin_size,GetNumberDensity);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, we forget to MPI-AllReduce the deposited charge to all ranks.

Will help fix that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Call charge deposition function
impactx::particles::wakefields::DepositCharge1D(particle_container, charge_distribution, bin_min, bin_size, is_unity_particle_weight);
// Sum up all partial charge histograms to one MPI process to calculate the global wakefield.
// Once calculated, we will distribute convolved_wakefield back to every MPI process.
amrex::ParallelReduce::Sum(
charge_distribution.data(),
charge_distribution.size(),
amrex::ParallelDescriptor::IOProcessorNumber(),
amrex::ParallelDescriptor::Communicator()
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we calc the derivatives.

Comment on lines +108 to +110
.. _examples-fodo-2p5dGaussian-sc:

FODO Cell with 2.5D Gaussian Space Charge Using Particle Tracking
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qianglbl this section of the README still needs to be finished, please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: space charge Space charge & potential solver tracking: particles

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants